package com.example.administrator.fastdream.view.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.administrator.fastdream.R;
import com.example.administrator.fastdream.date.bean.BaseBean;
import com.example.administrator.fastdream.date.bean.PersonalInfoBean;
import com.example.administrator.fastdream.date.bean.UploadPhotoBean;
import com.example.administrator.fastdream.date.presenter.PersonalInfoPresenter;
import com.example.administrator.fastdream.view.base.BaseActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MyWalletActivity extends BaseActivity implements PersonalInfoPresenter.PersonCallBack {

    @BindView(R.id.iv_mine)
    ImageView ivMine;
    @BindView(R.id.iv_back)
    ImageView ivBack;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.tv_right)
    TextView tvRight;
    @BindView(R.id.tv_money)
    TextView tvMoney;
    @BindView(R.id.tv_addcard)
    TextView tvAddcard;
    @BindView(R.id.tv_cardinfo)
    TextView tv_cardinfo;
    @BindView(R.id.tv_yes)
    TextView tvYes;
    public static final int RESULTCODE=1001;
    private PersonalInfoPresenter presenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_wallet);
        ButterKnife.bind(this);
        ivBack.setVisibility(View.VISIBLE);
        tvTitle.setText("我的余额");
        presenter = new PersonalInfoPresenter(this, this);
        presenter.getPersonalInfo();
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        setIntent(intent);
        tv_cardinfo.setText("招商银行(6618****8623)");
        tvAddcard.setVisibility(View.GONE);
    }

    @OnClick({R.id.iv_back, R.id.tv_addcard, R.id.tv_yes})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.iv_back:
                finish();
                break;
            case R.id.tv_addcard:
                startActivity(new Intent(mContext,AddBankCardActivity.class));
                break;
            case R.id.tv_yes:
                startActivityForResult(new Intent(mContext,TiXianActivity.class),0);
                break;
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        //点击了提现界面的知道了
        if (resultCode==TiXianActivity.RESULTCODE){
            setResult(resultCode,new Intent());
            finish();
        }
    }

    @Override
    public void getPersonalInfo(PersonalInfoBean personalInfoBean) {
        String money = personalInfoBean.getData().getUser_info().getBalance();
        tvMoney.setText(money);
    }

    @Override
    public void savePersonalInfo(BaseBean baseBean) {

    }

    @Override
    public void uploadPhotos(UploadPhotoBean uploadPhotoBean) {

    }
}
